package com.jrx.anytxn.transaction.job.autoPayment.step;

import com.jrx.anytxn.transaction.constant.TransBizConstant;
import com.jrx.anytxn.transaction.entity.TlPaymentLog;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.batch.MyBatisPagingItemReader;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 读取上次非足额扣款成功的流水
 */
public class AutoPaymentSecondInitReader2 extends MyBatisPagingItemReader<TlPaymentLog> {

    public AutoPaymentSecondInitReader2(Date businessDate, SqlSessionFactory sqlSessionFactory, Integer pagesize){
        //扣成功并且结清标识 settle_flag =0的数据
        setSaveState(false);
        setPageSize(pagesize);
        setSqlSessionFactory(sqlSessionFactory);
        setQueryId("com.jrx.anytxn.transaction.mapper.ext.ExtTlPaymentLogMapper.selectBySumStatusAndSettleFlag");
        Map<String, Object> map = new HashMap<>();
        map.put("sumStatus",TransBizConstant.PAYMENT_LOG_SUM_STATUS_S);
        map.put("paymentType", TransBizConstant.REPAYMENT_TYPE_AUTO);
        map.put("businessDate",businessDate);
        map.put("settleFlag",TransBizConstant.SETTLE_FLAG_0);

        setParameterValues(map);
    }
}
